package com.example.mapper;

import com.example.pojo.dto.EnrollCourseDto;
import com.example.pojo.dto.SelectCourseDto;
import com.example.pojo.entity.Course;
import com.example.pojo.vo.SelectCourseVo;
import com.example.pojo.vo.UserInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CourseMapper {

    /**
     * 如果同时传参年级和类别，则根据这两样查
     * @param selectCourseDto
     * @return
     */
    List<SelectCourseVo> getCourseByCateAndLevel(SelectCourseDto selectCourseDto);


    Integer addCourseNum(EnrollCourseDto enrollCourseDto);
    Integer dffCourseNum(EnrollCourseDto enrollCourseDto);
    List<String> getClassesByLevel(String level);

    @Select("select * from bx_course where course_id = #{id}")
    Course getCourseById(Integer id);

    @Update("UPDATE bx_course SET course_imagepath = #{path} WHERE course_id = #{courseId}")
    boolean updateCourseCoverImage(@Param("path") String path, @Param("courseId") Integer courseId);

    void updateCourse(Course course);

    @Update("UPDATE bx_grade_course SET grade_id = #{categoryId} WHERE course_id = #{courseId};")
    void updateCourseCate(Course course);

    List<UserInfoVo> getNumById(Integer id);
}
